home *** CD-ROM | disk | FTP | other *** search
-
- /*ARexx.c: This is the ARexx support code module*/
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <clib/intuition_protos.h>
- #include <clib/exec_protos.h>
- #include "minrexx.h"
- #include "arexx.h"
- #include <strings.h>
- #include <ctype.h>
- #include <stdlib.h>
-
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/intuition_pragmas.h>
- #include <pragmas/dos_pragmas.h>
-
- extern struct Library *SysBase;
- extern struct Library *IntuitionBase;
-
- struct RexxMsg *rexxMsg;
- BOOL rexxAbort=FALSE;
-
- extern char *version; /*DSound's version string*/
-
- void rQuit(char *p);
-
- struct rexxCommandList commandList[] =
- {
- { "quit" , (APTR)&rQuit }, /*Quit*/
- { NULL, NULL }
- };
-
- char portName[16];
- char arexxBuf[140];
-
-
- /*Open the ARexx port*/
- long initRexxPort(void)
- {
- determinePortName(portName); /*Get the port name*/
-
- /*Ask minrexx to open the port and return the port's signal bit*/
- return(upRexxPort(portName,commandList,"rx",(APTR)&disp));
- }
-
- char *result="RESULT";
- UBYTE errorNum=0;
-
- /*Determine what the ARexx port name should be. The first running instance*/
- /*of DSound should have an ARexx port named 'DSound.1'. The second, 'DSound.2'*/
- /*etc. This starts at 'DSound.1' and works up until it finds a free space*/
- /*(up to DSound.99)*/
- void determinePortName(char *portName)
- {
- ULONG c=1;
- UBYTE len;
-
- strcpy(portName,"DSound.");
-
- do
- {
- len=stcu_d(&portName[7],c++);
- portName[7+len]=NULL;
- }
- while(FindPort(portName)!=NULL && c<1000);
- if(FindPort(portName)!=NULL)
- exit(50);
- return;
- }
-
- /*The ARexx command dispatch function. This calls the functions associated*/
- /*with a particular command*/
- int disp(struct RexxMsg *msg,struct rexxCommandList *dat,char *p)
- {
- rexxMsg=msg;
-
- /*Call the function that supports the command*/
- ((int (*)())(dat->userdata))(p);
-
- /*Reply to ARexx, using the reply string and error number set by the*/
- /*function just called*/
- replyRexxCmd(rexxMsg,errorNum,0,arexxBuf);
- errorNum=0;
- return(1); /*1 means that minrexx shouldn't reply to the rexx message*/
- }
-
- /*Quit DSound*/
- void rQuit(char *p)
- {
- rexxAbort=TRUE;
- strcpy(arexxBuf,result);
- }
-
- /*End of ARexx.c*/
-
-